﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.Odbc; // Database
using System.Globalization;
using System.Data.Common; // Date 

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {


        System.Data.SQLite.SQLiteFactory fac = new System.Data.SQLite.SQLiteFactory();

        protected void Page_Load(object sender, EventArgs e)
        {
            
            string id = "invalid_wuliuid";

            string parmName = "wuliuID";

            if(null != Request.QueryString[parmName])
                id = Request.QueryString[parmName].ToString();

            using (DbConnection cnn = fac.CreateConnection())
            {
                cnn.ConnectionString = "Data Source=E:\\Release\\WuliuData.db";
//                cnn.ConnectionString = "Data Source=D:\\netDisk\\MyPro\\VS2010Pro\\ZWuliu\\Win32\\Debug\\WuliuData.db";
                cnn.Open();
                DbCommand sqlcmd = cnn.CreateCommand();

                
                sqlcmd.CommandText = "select curState,curStateOptTime from WuliuPackage where huoDanID=:ID;";
                
                DbParameter parmID = sqlcmd.CreateParameter();
                parmID.ParameterName = "ID";
                parmID.Value = id;
                parmID.DbType = DbType.String;
                parmID.Direction = ParameterDirection.Input;
                sqlcmd.Parameters.Add(parmID);

                DbDataReader data = sqlcmd.ExecuteReader();

                while (data.Read())
                {
                    TableRow r = new TableRow();
                    Table1.Controls.Add(r);

                    for (int i = 0; i < data.FieldCount; i++)
                    {
                        TableCell cell = new TableCell();
                        cell.Text = data.GetString(i);
                        r.Controls.Add(cell);
                    }
                }

                if (Table1.Rows.Count == 0)
                {
                    TableRow r = new TableRow();
                    Table1.Controls.Add(r);
                    TableCell cell = new TableCell();
                    cell.Text = "<div class=\"label label-danger\">没有任何记录</div>";
                        r.Controls.Add(cell);
                }
                cnn.Close();
            }

        }
    }
}
